#pragma once

#include <stdlib.h>     //exit
#include <string>
#define Die(code)   \
    do              \
    {               \
        exit(code); \
    } while (0)

enum exitCode
{
    SOCKET_ERR = 1,
    BIND_ERR,
    USE_ERR
};

#define CONVERSE(src) ((struct sockaddr*)src)

std::string gSeparator = ": ";
//字符串拆分
//apple: 苹果
bool SplitString(std::string& line,std::string& key,std::string& value)
{
    size_t pos = line.find(gSeparator);
    key = line.substr(0,pos);
    value = line.substr(pos+2);
    if(key.empty() || value.empty())
        return false;
    return true;
}